<!DOCTYPE html>
<html>
<body>
<script src="../../resources/visibility.js"></script>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function finish() {
    document.open();
    document.write("PASS. WebKit didn't crash");
    document.close();

    if (window.testRunner)
        testRunner.notifyDone();
}

function crash()
{     
    document.body.removeChild(document.getElementById("f"));
    setTimeout("finish()", 0);
}

frame = document.createElement("iframe");
frame.id = "f";
document.body.appendChild(frame);
scriptElement = frame.contentDocument.createElement("script");
frame.contentDocument.body.appendChild(scriptElement);
scriptElement.innerText = "function handleVisibilityChange() \
                           { \
                               parent.crash(); \
                           } \
                           document.addEventListener('visibilitychange', handleVisibilityChange, false);";

setMainWindowHidden(true);
</script>
</body>
</html>
